local extension = Package:new("nanzhong")
extension.extensionName = "Euphonium"

local U = require "packages/utility/utility"

Fk:loadTranslationTable{
    ["nanzhong"] = "南中",
}

--伞木希美
local sanmuximei = General:new(extension,"sanmuximei","th_k_nan",4,4,General.Female)
local nizhou = fk.CreateTriggerSkill{
  name = "nizhou",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish
    end,
    on_cost = function(self, event, target, player, data)
      local room = player.room
      local to = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper),
        1, 1, "#nizhou-choose", self.name, true)
      if #to > 0 then
        self.cost_data = {tos = to}
        return true
      end
    end,
  on_use = function(self, event, target, player, data)
    local room  = player.room
    local targets = room:getAlivePlayers()
    local to = room:getPlayerById(self.cost_data.tos[1])
    local cards = room:askForCard(player, 1, 2, true, self.name, true)
    local cards1, cards2 = Fk:getCardById(cards[1]), Fk:getCardById(cards[2])
    room:obtainCard(to, cards, false, fk.ReasonGive)
    if #cards > 1 and cards1:compareSuitWith(cards2) then
      room:recover{
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      }
    end
  end,

}



local qiji = fk.CreateTriggerSkill{
  name = "qiji",
  events = {fk.EventPhaseProceeding},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill("qiji") and player.phase == Player.Finish and player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local judge = {
      who = player,
      reason = self.name,
      pattern = ".|1~13",
    }
    room:judge(judge)
    if judge.card.number > 7 then
      player:drawCards(player.maxHp, self.name)
    end
    if judge.card.number<7 then
      player.room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    end
  end,
}

local nuli = fk.CreateTriggerSkill{
  name = "nuli",   --努力
  events = {fk.CardUseFinished},
  anim_type = "drawCard",
  can_trigger = function(self, event, target, player, data)
    if target ~= player or not player:hasSkill(self) or player.phase ~= Player.Play then return false end
    local card_type = data.card.type
    local room = player.room
    local logic = room.logic
    local use_event = logic:getCurrentEvent()
    local mark_name = "nulitrigger_" .. data.card:getTypeString() .. "-turn"
    local mark = player:getMark(mark_name)
    if mark == 0 then
      logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local last_use = e.data[1]
        if last_use.from == player.id and last_use.card.type == card_type then
          mark = e.id
          room:setPlayerMark(player, mark_name, mark)
          return true
        end
        return false
      end, Player.HistoryRound)
    end
    return mark == use_event.id
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
    player:addMark( "@nuli-turn", 1)
  end,
}
local nuli_maxcards = fk.CreateMaxCardsSkill{  --减少手牌上限效果
  name = "#nuli_maxcards",
  correct_func = function(self, player)
    return -player:getMark("@nuli-turn")
  end,
}
local nuli_tr = fk.CreateTriggerSkill{--触发弃牌效果
  name = "#nuli_tr",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)--触发条件  1.使用过牌
    local n = 0
    player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
      local use = e.data[1]
      if use.from == player.id then
        n = n + 1
      end
    end,Player.HistoryTurn)
    if player:hasSkill(self) and target == player and player.phase == Player.Discard and n>0 then
        local x = 0--2.使用牌的类型均不同
        local y = 0
        local z = 0 
        player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
          local use = e.data[1]
          if use.from == player.id then
            if use.card.type == Card.TypeBasic then
              x = x+1
            elseif use.card.type == Card.TypeTrick then
              y = y+1
            elseif use.card.type == Card.TypeEquip then
              z = z+1
            end
          end
        end, Player.HistoryTurn)
        if x<2 and y<2 and z<2 then
        return true
        end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(room.alive_players, function(p) return not p:isAllNude() end), Util.IdMapper)
      if #targets == 0 then return end
      local tos = room:askForChoosePlayers(player, targets, 1, 1, "#nuli-discard", self.name, false)
      local to = room:getPlayerById(tos[1])
      local card = room:askForCardChosen(player, to, "hej", self.name)
      room:throwCard({card}, self.name, to, player)
    end
}

local shiyun = fk.CreateFilterSkill{--时运
  name = "shiyun",
  frequency = Skill.Compulsory,
  card_filter = function(self, to_select, player, isJudgeEvent)
    return player:hasSkill(self) and isJudgeEvent
  end,
  view_as = function(self, to_select)
    return Fk:cloneCard(to_select.name, Card.NoSuit, to_select.number)
    end,
}
--添加技能
nuli:addRelatedSkill(nuli_maxcards)
nuli:addRelatedSkill(nuli_tr)
sanmuximei:addSkill(nuli)
sanmuximei:addSkill(shiyun)
sanmuximei:addSkill(qiji)
--sanmuximei:addSkill(nizhou1)
sanmuximei:addSkill(nizhou)
Fk:loadTranslationTable{
    ["sanmuximei"] = "伞木希美",
    ["#sanmuximei"] = "时运不济",
    ["shiyun"] = "时运",
    [":shiyun"] = "锁定技：你的判定牌均视为无花色。",
    [":nuli"] = "当你每回合首次使用一种类别的牌结算结束后，你可以摸一张牌，若如此做你本回合手牌上限-1，出牌阶段结束时，若你本回合使用牌的类型均不相同，则你可以弃置一名角色区域内一张牌。",
    ["nuli"] = "努力",
    ["@nuli-turn"] = "努力",
    ["@nuli"] = "努力",
    ["#nuli_tr"] = "努力",
    ["$shiyun"] = "我啊，是真的想去音大吗。",
    ["qiji"] = "奇迹",
    [":qiji"] = "结束阶段，若你没有手牌，你可以进行一次判定，若点数小于7，你回复一点体力，反之，你将手牌补充至体力上限。",
    ["#nizhou-choose"] = "逆舟：选择至多两张牌交一名角色。",
    ["#nuli-discard"] = "努力：弃置一名角色区域里的一张牌。",
    ["#nizhou1"] = "逆舟",
    ["nizhou"] = "逆舟",
    [":nizhou"] = "结束阶段开始时，你可以将至多两张牌交于一名其他角色，若你交出的牌大于一张且花色相同，则该角色可以令你回复一点体力。",
    --[":nizhou1"] = "转换技：阴：当你受到伤害时，你可以令其他角色计算与你距离+1至你下个出牌阶段结束，若如此做，你下个出牌阶段不能使用杀。阳：出牌阶段限一次，你可以将两张牌交于一名其他角色，若你交出的牌大于一张且花色相同，则该角色可以令你回复一点体力。",
    --["#nizhou_prohibit"] = "逆舟：禁止",
    --["@nizhou"] = "逆舟距离+",
    --["@@nzprohibit"] = "禁止用杀",
    --["@@nizhouyang"] = "阳"
}


--铠冢霙
local kaizongying = General:new(extension,"kaizongying","th_k_nan",3,4,General.Female)
local zhanchi = fk.CreateTriggerSkill{  --展翅
  name = "zhanchi",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)--触发条件
    return target == player and player:hasSkill("zhanchi") and data.card.type ~= Card.TypeBasic and player:usedSkillTimes("zhanchi", Player.HistoryPhase) < player.hp and player.phase == Player.Play
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local slash = Fk:cloneCard "slash"
    local max_num = slash.skill:getMaxTargetNum(player, slash)
    local targets = {}
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if not player:isProhibited(p, slash) and target:inMyAttackRange(p) then
        table.insert(targets, p.id)
      end
    end
    if #targets == 0 or max_num == 0 then return end
    local tos = room:askForChoosePlayers(player, targets, 1, max_num, "#zhanchi", self.name, true)
    if #tos > 0 then
      self.cost_data = tos
      return true
    end
  end,
  on_use = function(self, event, target, player, data)--视为使用雷杀
    local room = player.room
    local slash = Fk:cloneCard "slash"
    slash.skillName = self.name
    room:useCard {
      from = target.id,
      tos = table.map(self.cost_data, function(pid) return { pid } end),
      card = slash,
      extraUse = true,
    }
  end,
  }

local chongyuan = fk.CreateActiveSkill{--重圆
  name = "chongyuan",
  anim_type = "drawCard",
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and not player:isKongcheng()
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0
    end,
    target_filter = function(self, to_select, selected)
      local target = Fk:currentRoom():getPlayerById(to_select)
      return #selected == 0 and not target:isKongcheng() and Self:inMyAttackRange(target)
    end,
    on_use = function(self, room, effect)
      local player = room:getPlayerById(effect.from)
      local target = room:getPlayerById(effect.tos[1])
      local cardone = Fk:getCardById(effect.cards[1])
      local cardtwo = room:askForCardChosen(player, target, "h", self.name)
      room:obtainCard(target.id, cardone, true, fk.ReasonGive)
      room:obtainCard(player.id, cardtwo, true, fk.ReasonPrey)
      if cardone:compareColorWith(Fk:getCardById(cardtwo)) then
        player:drawCards(1, self.name)
        target:drawCards(1, self.name)
      end
    end
}

local kunfu_prohibit = fk.CreateAttackRangeSkill{--攻击距离为0
  name = "kunfu_prohibit",
  frequency = Skill.Compulsory,
  correct_func = function (self, from, to)
    if from:hasSkill("kunfu_prohibit") and not from:getEquipment(Card.SubtypeWeapon) then
      return -1000
    end
    return 0
  end,
}
local ying_tianfu = fk.CreateTriggerSkill{--摸牌
    name = "ying_tianfu",
    anim_type = "drawcard",
    events = {fk.DrawNCards},
    frequency = Skill.Compulsory,
    on_use = function(self, event, target, player, data)
      data.n = data.n + player.hp
    end,
  }
  local ying_tianfu_maxcards = fk.CreateMaxCardsSkill{--手牌上限
    name = "#ying_tianfu_maxcards",
    correct_func = function(self, player)
      if player:hasSkill(ying_tianfu.name) then
        return 1
      end
    end
  }
  ying_tianfu:addRelatedSkill(ying_tianfu_maxcards)--跳过判定阶段
  local ying_tianfupan = fk.CreateTriggerSkill{
    name = "#ying_tianfupan",
    events = {fk.EventPhaseChanging},
    frequency = Skill.Compulsory,
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and data.to == Player.Judge
    end,
    on_use = function(self, event, target, player, data)
      player:skip(player.Judge)
      return true
    end
  }
  --添加技能
  ying_tianfu:addRelatedSkill(ying_tianfupan)
  kaizongying:addSkill(ying_tianfu)
kaizongying:addSkill(kunfu_prohibit)
--kaizongying:addSkill(chongyuan)
kaizongying:addSkill(zhanchi)

local zhongchuanxiaji = General:new(extension,"zhongchuanxiaji","th_k_nan",4,4,General.Female)
local guao = fk.CreateTriggerSkill{
  name = "guao",
  anim_type = "offensive",
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    local target_t = player.room:getPlayerById(data.to)
    return player:hasSkill(self) and data.card.is_damage_card and not target_t:isNude() and not player:isNude() and target==player
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(AimGroup:getAllTargets(data.tos), function (id)
      return not room:getPlayerById(id).dead
    end)
    if #targets == 1 then
      if room:askForSkillInvoke(player, self.name, nil, "#guao-invoke::" .. targets[1]) then
        room:doIndicate(player.id, targets)
        self.cost_data = targets
        return true
      end
    else
      targets = room:askForChoosePlayers(player, targets, 1, 1, "guao-choose", self.name, true)
      if #targets > 0 then
        self.cost_data = targets
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    INTPLAY = player
    XIAJITO = room:getPlayerById(self.cost_data[1])
    local ids = room:askForDiscard(player,1,1,true,self.name, true,".", "guao_ask")
    local id = room:askForCardChosen(player, XIAJITO, "he", self.name)
    if event == fk.TargetSpecified then
      room:throwCard(ids, self.name, player, player)
      room:throwCard(id,self.name,XIAJITO,player)
    end
    data.extra_data = data.extra_data or {}
      data.extra_data.guao = data.extra_data.guao or {}
      table.insert(data.extra_data.guao, XIAJITO.id)
  end,
}

local guao_delay = fk.CreateTriggerSkill{
  name = "#guao_delay",
  mute = true,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if player.dead or data.card == nil or target ~= player then return false end
    local room = player.room
    local card_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    if not card_event then return false end
    local use = card_event.data[1]
    return use.extra_data and use.extra_data.guao and table.contains(use.extra_data.guao, player.id)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
   data.damage = data.damage + 1
   room:addPlayerMark(INTPLAY, "@guao-turn")
  end,
}
local guao_view = fk.CreateTriggerSkill{
  name = "#guao_view",
  events = {fk.CardUseFinished},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return not player.dead and not data.damageDealt and data.extra_data and data.extra_data.guao and target == player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:useVirtualCard("fire_attack", nil, XIAJITO, player)
  end
}


local guao_ex = fk.CreateTriggerSkill{
  name = "guao_ex",
  anim_type = "offensive",
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    local target_t = player.room:getPlayerById(data.to)
    return player:hasSkill(self) and data.card.is_damage_card and not target_t:isNude() and not player:isNude() and target==player and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(AimGroup:getAllTargets(data.tos), function (id)
      return not room:getPlayerById(id).dead
    end)
    if #targets == 1 then
      if room:askForSkillInvoke(player, self.name, nil, "#guao-invoke::" .. targets[1]) then
        room:doIndicate(player.id, targets)
        self.cost_data = targets
        return true
      end
    else
      targets = room:askForChoosePlayers(player, targets, 1, 1, "guao-choose", self.name, true)
      if #targets > 0 then
        self.cost_data = targets
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    XIAJITOex = room:getPlayerById(self.cost_data[1])
    local ids = room:askForDiscard(player,1,1,true,self.name, true,".", "guao_ask")
    local id = room:askForCardChosen(player, XIAJITOex, "he", self.name)
    if event == fk.TargetSpecified then
      room:throwCard(ids, self.name, player, player)
      room:throwCard(id,self.name,XIAJITOex,player)
    end
    data.extra_data = data.extra_data or {}
      data.extra_data.guao_ex = data.extra_data.guao_ex or {}
      table.insert(data.extra_data.guao_ex, XIAJITOex.id)
  end,
}

local guaoex_delay = fk.CreateTriggerSkill{
  name = "#guaoex_delay",
  mute = true,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if player.dead or data.card == nil or target ~= player then return false end
    local room = player.room
    local card_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    if not card_event then return false end
    local use = card_event.data[1]
    return use.extra_data and use.extra_data.guao_ex and table.contains(use.extra_data.guao_ex, player.id)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
   data.damage = data.damage + 1
  end,
}
local guaoex_view = fk.CreateTriggerSkill{
  name = "#guaoex_view",
  events = {fk.CardUseFinished},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return not player.dead and not data.damageDealt and data.extra_data_ex and data.extra_data.guao_ex and target == player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:useVirtualCard("fire_attack", nil, XIAJITOex, player)
  end
}

guao_ex:addRelatedSkill(guaoex_delay)
guao_ex:addRelatedSkill(guaoex_view)
zhongchuanxiaji:addRelatedSkill(guao_ex)









local moshi = fk.CreateTriggerSkill{
  name = "moshi",
  anim_type = "defensive",
  events = {fk.TargetConfirmed},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.type == Card.TypeTrick and #AimGroup:getAllTargets(data.tos) > 1 and player:usedSkillTimes(self.name, Player.HistoryTurn) < 1 and player:getMark("@@moshi-turn") == 0
  end,
  on_use = function(self, event, target, player, data)
    table.insertIfNeed(data.nullifiedTargets, player.id)
  end,
}
local moshi2 = fk.CreateTriggerSkill{
  name = "#moshi2",
  anim_type = "defensive",
  events = {fk.TargetConfirmed},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.type == Card.TypeTrick and #AimGroup:getAllTargets(data.tos) == 1 and player:usedSkillTimes(self.name, Player.HistoryTurn) < 1 and player:getMark("@@moshi-turn") == 0
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
}
local jinxi = fk.CreateTriggerSkill{
  name = "jinxi",
  frequency = Skill.Wake,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    return player:getMark("@guao-turn") > 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
        room:handleAddLoseSkills(player, "xiagu", nil, true, false)
        room:handleAddLoseSkills(player, "-guao", nil, true, false)
        room:handleAddLoseSkills(player, "guao_ex", nil, true, false)
  end
}
local xiagu = fk.CreateTriggerSkill{
  name = "xiagu",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not target.dead and target ~= player and not table.contains(U.getMark(target, "xiagumark-turn"), data.to.id)
   end,
   on_use = function(self, event, target, player, data)
    local room = player.room
    room:drawCards(player, 1, self.name)
    XIAGUto = event == fk.Damaged and data.to or data.from
    if player.dead or player:isNude() or XIAGUto.dead then return false end
    local card = room:askForCard(player, 1, 100, true, self.name, false, ".", "#xiagu")
    if #card > 0 then
      room:moveCardTo(card, Card.PlayerHand, XIAGUto, fk.ReasonGive, self.name, nil, false, player.id)
    end
    room:addPlayerMark(player, "@@moshi-turn")
    room:addPlayerMark(XIAGUto,"@xiagu")
    room:addPlayerMark(player,"@@xiaguself")
    local mark = U.getMark(player, "xiagumark-turn")
    table.insert(mark, data.to.id)
    player.room:setPlayerMark(target, "xiagumark-turn", mark)
  end
}
local xiagu_dagade = fk.CreateTriggerSkill{
  name = "#xiagu_dagade",
  anim_type = "negative",
  events = {fk.DamageInflicted},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target:getMark("@xiagu") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player, 1, self.name)
    room:removePlayerMark(XIAGUto, "@xiagu")
    room:removePlayerMark(player, "@@xiaguself")
  end
}
local xiagu_draw = fk.CreateTriggerSkill{
  name = "#xiagu_draw",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:getMark("@@xiaguself") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(player:getLostHp(), self.name)
    room:removePlayerMark(XIAGUto, "@xiagu")
    room:removePlayerMark(player, "@@xiaguself")
  end
}

xiagu:addRelatedSkill(xiagu_dagade)
xiagu:addRelatedSkill(xiagu_draw)
zhongchuanxiaji:addSkill(guao)
guao:addRelatedSkill(guao_delay)
guao:addRelatedSkill(guao_view)
moshi:addRelatedSkill(moshi2)
zhongchuanxiaji:addSkill(moshi)
zhongchuanxiaji:addSkill(jinxi)
zhongchuanxiaji:addRelatedSkill(xiagu)

local jichuanyouzi = General:new(extension,"jichuanyouzi","th_k_nan",4,4,General.Female)
local pianzhi = fk.CreateTriggerSkill{
  name = "pianzhi",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not target.dead and (target == player or player:distanceTo(target) == 1) and data.from~=player and player:canPindian(data.from)
   end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = event == fk.Damaged and data.from or data.to
    room:loseHp(player, 1, self.name)
    while not (player.dead or target.dead) and player:canPindian(target) do
      local pindian = player:pindian({target}, self.name)
      if pindian.results[target.id].winner ~= player then
        if not player.dead and not target.dead and player:canPindian(target)
        and room:askForSkillInvoke(player, self.name, nil, "#pianzhi::"..target.id) then
          room:loseHp(player, 1, self.name)
          player:broadcastSkillInvoke(self.name)
          room:notifySkillInvoked(player, self.name)
          room:doIndicate(player.id, {target.id})
        else
          break
        end
      else
        local use = room:useVirtualCard("slash", nil, player, target, self.name, false)
        if use.damageDealt then
          local n = 0
      for _, p in ipairs(player.room.players) do
        if use.damageDealt[p.id] then
          n = n + use.damageDealt[p.id]
        end
      end
        if not player.dead and player:isWounded() then
          room:recover{
            who = player,
            num =n,
            recoverBy = player,
            skillName = self.name
          }
        end
        break
      end
      break
      end
    end
  end,
}
jichuanyouzi:addSkill(pianzhi)
local mingche = fk.CreateTriggerSkill{
  name = "mingche",
  anim_type = "special",
  events = {fk.HpLost},
  on_trigger = function(self, event, target, player, data)
    for i = 1, data.num do
      if i > 1 and not player:hasSkill(self) then break end
      self:doCost(event, target, player, data)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = player.room:askForChoice(player, {"mingche_draw:", "mingche_damage:"}, self.name)
    if choice:startsWith("mingche_draw") then
      room:addPlayerMark(player, "@mingche_draw-turn")
      player:drawCards(2, self.name)
    else
      room:addPlayerMark(player, "@@mingche_damage-turn")
      room:changeMaxHp(player, -1)
    end
  end,
}
local mingche_distance = fk.CreateDistanceSkill{
  name = "#mingche_distance",
  correct_func = function(self, from, to)
    if from:hasSkill(self) then
      return from:getMark("@mingche_draw-turn")
  end
end
}
jichuanyouzi:addSkill(mingche)
mingche:addRelatedSkill(mingche_distance)
local mingche_trigger = fk.CreateTriggerSkill{
  name = "#mingche_trigger",
  mute = true,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("@@mingche_damage") > 0 and data.card.trueName == "slash"
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.additionalDamage = (data.additionalDamage or 0) + room:getPlayerById(data.to).hp - 1
    player.room:setPlayerMark(player, "@@mingche_damage-turn", 0)
  end,
}
mingche:addRelatedSkill(mingche_trigger)

Fk:loadTranslationTable{
    ["kaizongying"] = "铠冢霙",
    ["#kaizongying"] = "视野狭小",
    ["ying_tianfu"] = "天赋",
    [":ying_tianfu"] = "锁定技：你始终跳过判定阶段。摸牌阶段，你可以多摸X张牌。你的手牌上限始终＋1。（X为你的体力值）",
    ["kunfu_prohibit"] = "困缚",
    [":kunfu_prohibit"] = "锁定技：若你的装备区没有武器，则你始终视为装备“破碎的伞”。",
    ["#ying_tianfupan"] = "天赋",
    ["chongyuan"] = "重圆",
    [":chongyuan"] = "出牌阶段限一次，你可以选择攻击范围内的一名其他角色，并交于其一张牌，然后获得其一张手牌，若颜色相同，则你与其各摸一张牌。",
    ["zhanchi"] = "展翅",
    ["#zhanchi"] = "展翅：你可以视为使用【杀】",
    [":zhanchi"] = "当你于回合内前X次使用非基本牌时，你可以视为对一名其他角色使用一张不计入次数的杀。",
    ["$zhanchi"] = "我会继续吹双簧管。",
    ["zhongchuanxiaji"] = "中川夏纪",
    ["#zhongchuanxiaji"] = "温柔的奏者",
    ["guao"] = "孤傲",
    ["guao_ex"] = "孤傲",
    [":guao_ex"] = "当你使用伤害类牌指定目标时,你可以弃置你与其中一个目标各一张牌,然后此牌对该目标造成的伤害+1,若未对其造成伤害,则视为其对你使用一张“火攻”",
    [":guao"] = "当你使用伤害类牌指定目标时,你可以弃置你与其中一个目标各一张牌,然后此牌对该目标造成的伤害+1,若未对其造成伤害,则视为其对你使用一张“火攻”",
    ["guao_delay"] = "孤傲",
    ["guao-choose"] = "选择一名玩家",
    ["guao_ask"] = "弃置你的一张牌",
    ["#guao-invoke"] = "孤傲",
    ["@guao-turn"] = "孤傲",
    ["moshi"] = "漠视",
    [":moshi"] = "每回合各限一次，你成为锦囊牌的目标时，若此牌目标数不为1,则你可以令此牌对你无效,若目标数为1，则你可以摸一张牌。",
    ["#moshi2"] = "漠视:摸一张牌",
    ["@@moshi-turn"] = "漠视失效",
    ["jinxi"] = "今夕",
    [":jinxi"] = "觉醒技:结束阶段,若你发动“孤傲”并造成的伤害大于等于一次,则你修改“孤傲”为“每回合限一次”并获得“侠骨”。",
    ["xiagu"] = "侠骨",
    [":xiagu"] = "当一名其他角色受到伤害时,你可以令本回合“漠视”失效并摸一张牌,然后将任意张牌交于其,本回合结束时,若其没有再次受到伤害,则你摸X张牌,否则你失去1点体力。（X为你已损失的体力值)",
    ["#xiagu"] = "选择任意张牌交给%dest",
    ["@xiagu"] = "侠骨",
    ["@@xiaguself"] = "侠骨",
    ["#xiagu_draw"] = "侠骨",
    ["#xiagu_dagade"] = "侠骨",
    ["#guaoex_view"] = "孤傲",
    ["#guao_view"] = "孤傲",
    ["#pianzhi"] = "偏执：你可以继续发动“偏执”与 %dest 拼点",
    ["jichuanyouzi"] = "吉川优子",
    ["#jichuanyouzi"] = "狂热的仰慕",
    ["pianzhi"] = "偏执",
    [":pianzhi"] = "当一名角色受到伤害后，若你与其距离1以内，则你可以失去1点体力与伤害来源进行拼点;若你没赢,你可以重复此流程;若你赢，则视为你对拼点角色使用一张无视距离的杀，若此杀造成伤害，则你回复等量体力。",
    ["mingche"] = "明澈",
    [":mingche"] = "当你失去1点体力时，你可以选择一项:1.摸两张牌，然后本回合与其他角色计算距离＋1;2.减少1点体力上限，本回合使用的下一张杀的伤害值改为目标角色当前的体力值。",
    ["@mingche_draw-turn"] ="距离＋",
    ["@@mingche_damage"] = "明澈",
    ["mingche_draw"] = "摸两张牌，然后本回合与其他角色计算距离＋1",
    ["mingche_damage"] = "减少1点体力上限，本回合使用的下一张杀的伤害值改为目标角色当前的体力值。",
    ["#mingche_trigger"] = "明澈",
}
return extension
